// @FileName  :t2.c
// @Time      :2024/4/5 0:04
// @Author    :YKW
//# include <bits/stdc++.h>
//using namespace std;
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <string.h>
# include <stdlib.h>

typedef struct node {
    int line;
    char bracket;
} node;

int isL(char c) {
    if (c == '(' || c == '{')
        return 1;
    return 0;
}

int isR(char c) {
    if (c == ')' || c == '}')
        return 1;
    return 0;
}

char toR(char l) {
    if (l == '(') return ')';
    if (l == '{') return '}';
}

node _s[250];
char _all[250];
char line[250];

int main() {
    int top = -1, top_a = -1, cnt = 0;
    int isComment = 0, dquote = 0, squote = 0;
    freopen("example.c", "r", stdin);
    while (gets(line) != NULL) {
//        puts(line);
        cnt++;
        for (int i = 0; i < strlen(line); i++) {
            if (squote) {
                if (line[i] == '\'') squote = 0;
                continue;
            } else if (dquote) {
                if (line[i] == '"') dquote = 0;
                continue;
            } else if (isComment) {
                if (line + i == strstr(line, "*/")) isComment = 0;
                continue;
            }
            if (line + i == strstr(line, "//"))break;
            if (line + i == strstr(line, "/*"))isComment = 1;
            if (line[i] == '\'')squote = 1;
            else if (line[i] == '"')dquote = 1;
            else if (line[i] == '(') {
                _all[++top_a] = '(';
                _s[++top].bracket = '(';
                _s[top].line = cnt;
            } else if (line[i] == ')') {
                _all[++top_a] = ')';
                if (top < 0 || _s[top].bracket != '(') {
                    printf("without maching ')' at line %d\n", cnt);
                    return 0;
                } else
                    top--;
            } else if (line[i] == '{') {
                _all[++top_a] = '{';
                if (top == -1 || (top >= 0 && _s[top].bracket != '(')) {
                    _s[++top].bracket = '{';
                    _s[top].line = cnt;
                } else {
                    printf("without maching '(' at line %d\n", _s[top].line);
                    return 0;
                }
            } else if (line[i] == '}') {
                _all[++top_a] = '}';
                if (top < 0 || _s[top].bracket != '{') {
                    printf("without maching '}' at line %d\n", cnt);
                    return 0;
                } else
                    top--;
            }
        }
    }
    if (top != -1)
        printf("without maching '%c' at line %d", _s[top].bracket, _s[top].line);
    else
        for (int i = 0; i <= top_a; i++)
            printf("%c", _all[i]);
}